<?php 
$sort1=isset($_GET['sort'])?'&sort='.$_GET['sort']:'';
$cs=Yii::app()->clientScript;
$cs->registerScript('truck_exam_excel',<<<END
$("#excel").click(
function(){
	var act=$("form").attr('action');
	$("form").attr('action',act+'&excel=1$sort1').attr('target','_blank').submit().attr('action',act).attr('target','');
}
);
END
);
$cs->registerScript('truck_exam_time_mode',<<<END
function change_mode(){
	if($("#time_mode").length==0||$("#time_mode").val()==1){
		$(".edate").hide();
		Calendar.setup({inputField:'s_date',ifFormat:'%Y-%m',weekNumbers:''});
		if($.trim($("#s_date").val())!=''&&$("#s_date").val().length==10) $("#s_date").val($("#s_date").val().substr(0,7));
	} 
	else{
		$(".edate").show();
		Calendar.setup({inputField:'s_date',ifFormat:'%Y-%m-%d',weekNumbers:''});
		if($.trim($("#s_date").val())!=''&&$("#s_date").val().length==7) $("#s_date").val($("#s_date").val()+'-01');
	}
}
$("#time_mode").change(change_mode);
change_mode();
END
);
?>
<h2>车辆考核汇总</h2>
<?php echo CHtml::beginForm(array('truck_exam'),'post');?>
<table  style="margin: 0 auto;"  width="2575">
<tr><td>
	<!--查询方式:<?php echo CHtml::dropDownList('time_mode', isset($_GET['time_mode'])?$_GET['time_mode']:1, array('0'=>'天','1'=>'月'));?>-->
	车牌号：<input type="text" name="keys[plate_no]" size="5" value="<?php echo isset($_GET['keys']['plate_no'])?$_GET['keys']['plate_no']:'';?>"/>
	主车司机：<input type="text" name="keys[main_driver_name]" size="5" value="<?php echo isset($_GET['keys']['main_driver_name'])?$_GET['keys']['main_driver_name']:'';?>"/>
	时间：<span class="edate">从</span><input type="text" id="s_date" name="keys[s_date]" size="7" value="<?php echo isset($_GET['keys']['s_date'])?$_GET['keys']['s_date']:'';?>"/>
	<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'s_date','ifFormat'=>'%Y-%m-%d'));?>
	<span class="edate">至<input type="text" id="e_date" name="keys[e_date]" size="7" value="<?php echo isset($_GET['keys']['e_date'])?$_GET['keys']['e_date']:'';?>"/></span>
	<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'e_date','ifFormat'=>'%Y-%m-%d'));?>
	模糊查询：<?php echo CHtml::radioButtonList('keys[blur]',isset($_GET['keys']['blur'])?$_GET['keys']['blur']:1,array(1=>'是',0=>'否'),array('separator'=>' '));?>
	<input type="submit" value="搜索"/>&nbsp;&nbsp;&nbsp;&nbsp;<input id="excel" type="button" value="输出excel文件"/>
</td></tr></table>
<?php echo CHtml::endForm();?>
<table class="dataGrid" width="2575">
  <thead>
   <tr>
    <th width="70" rowspan="2"><?php echo $sort->link('plate_no'); ?></th>
    <th width="60" rowspan="2"><?php echo $sort->link('main_driver_name'); ?></th>
    <th width="130" rowspan="2"><?php echo $sort->link('type_name'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('to_income'); ?></th>
    <th colspan="8">日常费用</th>
    <th colspan="8">固定费用</th>
    <th width="75" rowspan="2"><?php echo $sort->link('root_cost'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('total_cost'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('profit'); ?></th>
    <th width="50" rowspan="2"><?php echo $sort->link('merit_pay_kind'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('merit_pay'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('merit_pay_ratio'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('actual_salary'); ?></th>
    <th width="50" rowspan="2"><?php echo $sort->link('truck_kind'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('gas_ratio'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('bridge_ratio'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('rapair_ratio'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('amerce_ratio'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('other_ratio'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('profit_ratio'); ?></th>
    <th width="70" rowspan="2"><?php echo $sort->link('stat_date'); ?></th>
  </tr>
  <tr>
    
    
    <th width="70"><?php echo $sort->link('salary'); ?></th>
    <th width="70"><?php echo $sort->link('gas_fee'); ?></th>
    <th width="70"><?php echo $sort->link('bridge_charge'); ?></th>
    <th width="70"><?php echo $sort->link('maintain_fee'); ?></th>
    <th width="70"><?php echo $sort->link('repair_fee'); ?></th>
    <th width="70"><?php echo $sort->link('amerce_fee'); ?></th>
    <th width="70"><?php echo $sort->link('reparation'); ?></th>
    <th width="70"><?php echo $sort->link('other_fee'); ?></th>
    <th width="70"><?php echo $sort->link('depreciation'); ?></th>
    <th width="70"><?php echo $sort->link('insure_fee'); ?></th>
    <th width="70"><?php echo $sort->link('managing_cost'); ?></th>
    <th width="90"><?php echo $sort->link('salary_cost'); ?></th>
    <th width="70"><?php echo $sort->link('gps_fee'); ?></th>
    <th width="100"><?php echo $sort->link('mm_cost'); ?></th>
    <th width="100"><?php echo $sort->link('gi_cost'); ?></th>
    <th width="100"><?php echo $sort->link('avi_cost'); ?></th>
    
  </tr>
  </thead>
  <tbody>
<?php foreach($models as $n=>$model): ?>
  <tr class="<?php echo $n%2?'even':'odd';?>">
    <td><?php echo $model->plate_no; ?></td>
    <td><?php echo CHtml::encode($model->main_driver_name); ?></td>
    <td><?php echo CHtml::encode($model->type_name); ?></td>
    <td><?php echo CHtml::encode($model->to_income); ?></td>
    <td><?php echo CHtml::encode($model->salary); ?></td>
    <td><?php echo CHtml::encode($model->gas_fee); ?></td>
    <td><?php echo CHtml::encode($model->bridge_charge); ?></td>
    <td><?php echo CHtml::encode($model->maintain_fee); ?></td>
    <td><?php echo CHtml::encode($model->repair_fee); ?></td>
    <td><?php echo CHtml::encode($model->amerce_fee); ?></td>
    <td><?php echo CHtml::encode($model->reparation); ?></td>
    <td><?php echo CHtml::encode($model->other_fee); ?></td>
    <td><?php echo CHtml::encode($model->depreciation); ?></td>
    <td><?php echo CHtml::encode($model->insure_fee); ?></td>
    <td><?php echo CHtml::encode($model->managing_cost); ?></td>
    <td><?php echo CHtml::encode($model->salary_cost); ?></td>
    <td><?php echo CHtml::encode($model->gps_fee); ?></td>
    <td><?php echo CHtml::encode($model->mm_cost); ?></td>
    <td><?php echo CHtml::encode($model->gi_cost); ?></td>
    <td><?php echo CHtml::encode($model->avi_cost); ?></td>
    <td><?php echo CHtml::encode($model->root_cost); ?></td>
    <td><?php echo CHtml::encode($model->total_cost); ?></td>
    <td><?php echo CHtml::encode($model->profit); ?></td>
    <td><?php echo CHtml::encode($model->merit_pay_kind); ?></td>
    <td><?php echo CHtml::encode($model->merit_pay); ?></td>
    <td><?php echo CHtml::encode($model->merit_pay_ratio); ?></td>
    <td><?php echo CHtml::encode($model->actual_salary); ?></td>
    <td><?php echo CHtml::encode($model->truck_kind); ?></td>
    <td><?php echo CHtml::encode($model->gas_ratio); ?></td>
    <td><?php echo CHtml::encode($model->bridge_ratio); ?></td>
    <td><?php echo CHtml::encode($model->rapair_ratio); ?></td>
    <td><?php echo CHtml::encode($model->amerce_ratio); ?></td>
    <td><?php echo CHtml::encode($model->other_ratio); ?></td>
    <td><?php echo CHtml::encode($model->profit_ratio); ?></td>
    <td><?php echo CHtml::encode($model->stat_date); ?></td>
  </tr>
<?php endforeach; ?>
  </tbody>
</table>
<br/>
<?php $this->widget('CLinkPager',array('pages'=>$pages,'htmlOptions'=>array('style'=>'width:2575px;'))); ?>